<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>后盾人</title>
  </head>
  <body>
    <script>
      // const hd = "houdunren.com";
      // console.log(hd.replace("houdunren", "hdcms"));

      const word = ["php", "css"];
      const string = "我喜欢在后盾人学习php与css知识";
      const replaceString = word.reduce(
        (pre, word) => pre.replace(word, `<a href="?w=${word}">${word}</a>`),
        string
      );
      console.log(replaceString);
      document.body.innerHTML += replaceString;
    </script>
  </body>
</html>
